//
// Created by Vincent-Vic on 2020/3/11.
//

#include "Test.h"
#include "../Heap/HeapSort.h"
#include <ctime>
#include <../BinarySearch/AVL.h>
#include <../BinarySearch/BinarySearchTree.h>
#include <MinHeap.h>

void Test::testCMapV1() {
    CMap* cMap = new CMap(8);

    //创建节点数据
    cMap->addNode(new Node('A'));
    cMap->addNode(new Node('B'));
    cMap->addNode(new Node('C'));
    cMap->addNode(new Node('D'));
    cMap->addNode(new Node('E'));
    cMap->addNode(new Node('F'));
    cMap->addNode(new Node('G'));
    cMap->addNode(new Node('H'));

    //设置位置
    cMap->setValueToMatrixForUndirectedGraph(0,1);
    cMap->setValueToMatrixForUndirectedGraph(0,3);
    cMap->setValueToMatrixForUndirectedGraph(1,2);
    cMap->setValueToMatrixForUndirectedGraph(1,5);
    cMap->setValueToMatrixForUndirectedGraph(3,6);
    cMap->setValueToMatrixForUndirectedGraph(3,7);
    cMap->setValueToMatrixForUndirectedGraph(6,7);
    cMap->setValueToMatrixForUndirectedGraph(2,4);
    cMap->setValueToMatrixForUndirectedGraph(4,5);

    cMap->printMatrix();
    cout<<endl;
    cMap->depthFirstTraverse(0);
    cout<<endl;
    cMap->resetNode();
    cMap->breadthFirstTraverse(0);
}
void Test::testHeapV3() {
    int* HeapData = new int[100];
    srand(time(NULL));
    for (int i = 0; i < 100; ++i)
        HeapData[i] = rand() % 150;
    HeapSort<int> sort = HeapSort<int>();
    sort.heapSort_V3(HeapData,100);
    for (int i = 0; i < 100; ++i) {
        cout<<HeapData[i]<<",";
    }
    cout<<endl<<"---------------"<<endl;
}

void Test::testHeapV2() {
    int* HeapData = new int[100];
    srand(time(NULL));
    for (int i = 0; i < 100; ++i)
        HeapData[i] = rand() % 150;
    HeapSort<int> sort = HeapSort<int>();
    sort.heapSort_V2(HeapData,100);

    for (int i = 0; i < 100; ++i) {
        cout<<HeapData[i]<<",";
    }
    cout<<endl<<"---------------"<<endl;
}

void Test::testHeapV1() {
    int* HeapData = new int[100];
    srand(time(NULL));
    for (int i = 0; i < 100; ++i)
        HeapData[i] = rand() % 150;
    HeapSort<int> sort = HeapSort<int>();
    sort.heapSort_V1(HeapData,100);

    for (int i = 0; i < 100; ++i) {
        cout<<HeapData[i]<<",";
    }
    cout<<endl<<"---------------"<<endl;
}
void Test::testminHeapV1() {
    int* HeapData = new int[100];
    srand(time(NULL));
    for (int i = 0; i < 100; ++i)
        HeapData[i] = rand() % 150;
    MinHeap<int> min = MinHeap<int>(100);
    for (int i = 0; i < 100; ++i)  //将arr入二叉树堆
        min.insert(HeapData[i]);
    for (int i = 99; i >= 0; --i)  //从小的到大排序
        cout<< min.extractMin()<<endl;

    cout<<endl<<"---------------"<<endl;
}
void Test::testAVL() {
    AVL<int,int> map;

    for (int i = 0; i < 100; ++i) {
        map.insert(i,i*i*2);
    }

    for (int i = 40; i < 60; ++i) {
        map.remove(i);
    }

    cout<<endl;
    cout<< map.isBST() << endl;
    cout<< map.isBalanced() << endl;


}

void Test::testBST() {

    BinarySearchTree<int,int> map;
    for (int i = 0; i < 100; ++i) {
        map.insert(i,i*i*2);
    }

    map.inOrder();

}
